


const pros1 = new Promise((resolve, reject) => {
    // 获取文章数量
    $.ajax({
        url: `${baseUrl}/posts/count`,
        success: function (result) {
            resolve(result)
        },
        error: function (err) {
            console.log('获取文章数量失败');
            reject(err)
        }
    })
})


const pros2 = new Promise((resolve, reject) => {
    // 获取分类数量
    $.ajax({
        url: `${baseUrl}/categories/count`,
        success: function (result) {
            resolve(result)
        },
        error: function (err) {
            console.log('获取分类数量失败');
            reject(err)
        }
    })
})


const pros3 = new Promise((resolve, reject) => {
    // 获取评论数量
    $.ajax({
        url: `${baseUrl}/comments/count`,
        success: function (result) {
            resolve(result)
        },
        error: function (err) {
            console.log('获取评论数量失败');
            reject(err)
        }

    })
})
// console.log(pros1);

// Promise.all

Promise.all([pros1, pros2, pros3]).then(res => {
    let tempObj = {}
    // console.log(res);
    res.forEach(item => {
        for(let key in item) {
            tempObj[key] = item[key]
        }
    })
    // console.log(tempObj);
    const newHtml = template('list-group-id', tempObj)
    $('.list-group').html(newHtml)
}).catch(err => {
    console.log(err);
})




